home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / hmcv14_1.zip / HMCARD.MST < prev    next >
Text File  |  1994-12-29  |  12KB  |  433 lines

  1. '*********************** HM-Card Setup ************************************
  2.  
  3. '$DEFINE DEBUG  ''Define for debugging
  4.  
  5. '$INCLUDE 'setupapi.inc'
  6. '$INCLUDE 'msdetect.inc'
  7.  
  8. ''Dialog ID's
  9. CONST ASKQUIT      = 200
  10. CONST DESTPATH     = 300
  11. CONST EXITFAILURE  = 400
  12. CONST EXITQUIT     = 600
  13. CONST EXITSUCCESS  = 700
  14. CONST OPTIONS      = 800
  15. CONST APPHELP      = 900
  16. CONST CUSTINST     = 6200
  17. CONST TOOBIG       = 6300
  18. CONST BADPATH      = 6400
  19.  
  20. ''Bitmap ID
  21. CONST LOGO         = 1
  22.  
  23. ''File Types
  24. CONST APPFILES     = 1
  25. CONST OPTFILES1    = 2
  26.  
  27. GLOBAL DEST$        ''Default destination directory.
  28. GLOBAL DEST1OPT$    ''Default destination directory for optional files.
  29. GLOBAL WINDRIVE$    ''Windows drive letter.
  30. GLOBAL OPT1OPT$     ''Option selection from OptFiles1 option dialog.
  31.  
  32. ''CustInst list symbol names
  33. GLOBAL APPNEEDS$    ''Option list costs per drive
  34. GLOBAL OPT1NEEDS$
  35. GLOBAL EXTRACOSTS$  ''List of extra costs to add per drive
  36. GLOBAL BIGLIST$     ''List of option files cost calc results (boolean)
  37.  
  38. ''Dialog list symbol names
  39. GLOBAL CHECKSTATES$
  40. GLOBAL STATUSTEXT$
  41. GLOBAL DRIVETEXT$
  42.  
  43. DECLARE SUB AddOptFilesToCopyList (ftype%)
  44. DECLARE SUB RecalcOptFiles (ftype%)
  45. DECLARE SUB RecalcPath
  46. DECLARE SUB SetDriveStatus
  47. DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  48.  
  49.  
  50. INIT:
  51.     CUIDLL$ = "mscuistf.dll"            ''custom user interface dll
  52.     HELPPROC$ = "FHelpDlgProc"          ''Help dialog procedure
  53.  
  54.     SetBitmap CUIDLL$, LOGO
  55.     SetTitle "HM-Card Setup"
  56.  
  57.     szInf$ = GetSymbolValue("STF_SRCINFPATH")
  58.     IF szInf$ = "" THEN
  59.         szInf$ = GetSymbolValue("STF_CWDDIR") + "HMCARD.INF"
  60.     END IF
  61.     ReadInfFile szInf$
  62.  
  63.     WINDRIVE$ = MID$(GetWindowsDir, 1, 1)
  64.     DEST$ = WINDRIVE$ + ":\HMCARD"
  65.     DEST1OPT$ = DEST$
  66.  
  67.     ''CustInst list symbols
  68.     CHECKSTATES$ = "CheckItemsState"
  69.     STATUSTEXT$  = "StatusItemsText"
  70.     DRIVETEXT$   = "DriveStatusText"
  71.     FOR i% = 1 TO 2 STEP 1
  72.         AddListItem CHECKSTATES$, "ON"
  73.     NEXT i%
  74.     FOR i% = 1 TO 2 STEP 1
  75.         AddListItem STATUSTEXT$, ""
  76.     NEXT i%
  77.     FOR i% = 1 TO 7 STEP 1
  78.         AddListItem DRIVETEXT$, ""
  79.     NEXT i%
  80.     ReplaceListItem DRIVETEXT$, 7, DEST$
  81.  
  82.     ''Disk cost list symbols
  83.     APPNEEDS$   = "AppNeeds"
  84.     OPT1NEEDS$  = "Opt1Needs"
  85.     EXTRACOSTS$ = "ExtraCosts"
  86.     BIGLIST$    = "BigList"
  87.     FOR i% = 1 TO 2 STEP 1
  88.         AddListItem BIGLIST$, ""
  89.     NEXT i%
  90.     FOR i% = 1 TO 26 STEP 1
  91.         AddListItem EXTRACOSTS$, "0"
  92.     NEXT i%
  93.  
  94.     ''File Option Variables
  95.     OPT1OPT$ = "1"
  96.  
  97.     RecalcPath
  98.     SetDriveStatus
  99.  
  100. '$IFDEF DEBUG
  101.     i% = SetSizeCheckMode(scmOnIgnore)    '' could use scmOff; def = scmOnFatal
  102. '$ENDIF ''DEBUG
  103.  
  104.  
  105. CUSTINST:
  106.     sz$ = UIStartDlg(CUIDLL$, CUSTINST, "FCustInstDlgProc", APPHELP, HELPPROC$)
  107.  
  108.     IF sz$ = "CONTINUE" THEN
  109.         ''Install only if it will fit.
  110.         FOR i% = 1 TO 2 STEP 1
  111.             IF GetListItem(BIGLIST$, i%) <> "" THEN
  112.                 GOSUB TOOBIG
  113.                 GOTO CUSTINST
  114.             END IF
  115.         NEXT i%
  116.         UIPop 1
  117.         GOTO INSTALL
  118.     ELSEIF sz$ = "PATH" THEN
  119.         GOTO GETPATH
  120.     ELSEIF sz$ = "CHK1" THEN
  121.         RecalcOptFiles APPFILES
  122.         SetDriveStatus
  123.         GOTO CUSTINST
  124.     ELSEIF sz$ = "CHK2" THEN
  125.         RecalcOptFiles OPTFILES1
  126.         SetDriveStatus
  127.         GOTO CUSTINST
  128.     ELSEIF sz$ = "REACTIVATE" THEN
  129.         RecalcPath
  130.         SetDriveStatus
  131.         GOTO CUSTINST
  132.     ELSE
  133.         GOSUB ASKQUIT
  134.         GOTO CUSTINST
  135.     END IF
  136.  
  137.  
  138.  
  139. INSTALL:
  140.     ClearCopyList
  141.     AddOptFilesToCopyList APPFILES
  142.     DEST1OPT$ = DEST$ + "\DEMO"
  143.     AddOptFilesToCopyList OPTFILES1
  144.     CreateDir DEST$, cmoNone
  145.     CreateDir DEST1OPT$, cmoNone
  146.     CopyFilesInCopyList
  147.  
  148.     IF GetListItem(CHECKSTATES$, APPFILES) = "ON" THEN
  149.         RemoveIniSection MakePath(GetWindowsDir, "WIN.INI"), "HM-Card", cmoNone
  150.         CreateIniKeyValue MakePath(GetWindowsDir, "WIN.INI"), "HM-Card", "Dir", DEST$, cmoNone
  151.  
  152.         CreateProgmanGroup "HM-Card", "", cmoNone
  153.         CreateProgmanItem "HM-Card", "Linker", MakePath(DEST$,"hmc_link.exe"), "", cmoOverwrite
  154.         CreateProgmanItem "HM-Card", "Editor", MakePath(DEST$,"hmc_edit.exe"), "", cmoOverwrite
  155.         CreateProgmanItem "HM-Card", "Executor", MakePath(DEST$,"hmc_exec.exe"), "", cmoOverwrite
  156.  
  157.      IF GetListItem(CHECKSTATES$, OPTFILES1) = "ON" THEN
  158.          CreateProgmanItem "HM-Card", "Demo", MakePath(DEST$,"hmc_exec.exe -h -w -a")+MakePath(DEST1OPT$,"demo"), "", cmoOverwrite
  159.          CreateProgmanItem "HM-Card", "AutoDemo", MakePath(DEST$,"hmc_exec.exe -h -m")+MakePath(DEST1OPT$,"tour"), "", cmoOverwrite
  160.      END IF
  161.  
  162.     END IF
  163.  
  164.  
  165. QUIT:
  166.     ON ERROR GOTO ERRQUIT
  167.  
  168.     IF ERR = 0 THEN
  169.         dlg% = EXITSUCCESS
  170.     ELSEIF ERR = STFQUIT THEN
  171.         dlg% = EXITQUIT
  172.     ELSE
  173.         dlg% = EXITFAILURE
  174.     END IF
  175. QUITL1:
  176.     sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
  177.     IF sz$ = "REACTIVATE" THEN
  178.         GOTO QUITL1
  179.     END IF
  180.     UIPop 1
  181.  
  182.     IF DoesIniKeyExist (MakePath(GetWindowsDir, "SYSTEM.INI"), "drivers", "wave") = 0 THEN
  183.        i% = DoMsgBox("Sound driver has been added during HM-Card setup. We recommend to restart Windows in order to get sound effects.", "Sound driver installation message", MB_ICONASTERISK+MB_OK)
  184.        CreateIniKeyValue MakePath(GetWindowsDir, "SYSTEM.INI"), "drivers", "wave", MakePath(DEST$,"speaker.drv"), cmoNone
  185.     END IF
  186.  
  187.     END
  188.  
  189. ERRQUIT:
  190.     i% = DoMsgBox("Setup sources were corrupted!", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  191.     END
  192.  
  193.  
  194.  
  195. GETPATH:
  196.     SetSymbolValue "EditTextIn", DEST$
  197.     SetSymbolValue "EditFocus", "END"
  198. GETPATHL1:
  199.     sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, HELPPROC$)
  200.  
  201.     IF sz$ = "CONTINUE" THEN
  202.         olddest$ = DEST$
  203.         DEST$ = GetSymbolValue("EditTextOut")
  204.  
  205.         ''Validate new path.
  206.         IF IsDirWritable(DEST$) = 0 THEN
  207.             GOSUB BADPATH
  208.             GOTO GETPATHL1
  209.         END IF
  210.         UIPop 1
  211.  
  212.         ''Truncate display if too long.
  213.         IF LEN(DEST$) > 23 THEN
  214.             ReplaceListItem DRIVETEXT$, 7, MID$(DEST$, 1, 23)+"..."
  215.         ELSE
  216.             ReplaceListItem DRIVETEXT$, 7, DEST$
  217.         END IF
  218.  
  219.         ''Recalc if path changed.
  220.         IF (olddest$ <> DEST$) AND (olddest$ <> DEST$+"\") AND (olddest$+"\" <> DEST$) THEN
  221.             RecalcPath
  222.             SetDriveStatus
  223.         END IF
  224.  
  225.         olddest$ = ""
  226.         GOTO CUSTINST
  227.     ELSEIF sz$ = "REACTIVATE" THEN
  228.         RecalcPath
  229.         SetDriveStatus
  230.         GOTO GETPATHL1
  231.     ELSEIF sz$ = "EXIT" THEN
  232.         GOSUB ASKQUIT
  233.         GOTO GETPATHL1
  234.     ELSE
  235.         UIPop 1
  236.         GOTO CUSTINST
  237.     END IF
  238.  
  239.  
  240. TOOBIG:
  241.     sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfo0DlgProc", 0, "")
  242.     IF sz$ = "REACTIVATE" THEN
  243.         RecalcPath
  244.         SetDriveStatus
  245.         GOTO TOOBIG
  246.     END IF
  247.     UIPop 1
  248.     RETURN
  249.  
  250.  
  251.  
  252. BADPATH:
  253.     sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
  254.     IF sz$ = "REACTIVATE" THEN
  255.         RecalcPath
  256.         SetDriveStatus
  257.         GOTO BADPATH
  258.     END IF
  259.     UIPop 1
  260.     RETURN
  261.  
  262.  
  263.  
  264. ASKQUIT:
  265.     sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
  266.  
  267.     IF sz$ = "EXIT" THEN
  268.         UIPopAll
  269.         ERROR STFQUIT
  270.     ELSEIF sz$ = "REACTIVATE" THEN
  271.         GOTO ASKQUIT
  272.     ELSE
  273.         UIPop 1
  274.     END IF
  275.     RETURN
  276.  
  277.  
  278.  
  279. '**
  280. '** Purpose:
  281. '**     Adds the specified option files to the copy list.
  282. '** Arguments:
  283. '**     ftype%  - type of files to add, one of the following:
  284. '**             APPFILES, OPTFILES1
  285. '** Returns:
  286. '**     none.
  287. '*************************************************************************
  288. SUB AddOptFilesToCopyList (ftype%) STATIC
  289.  
  290.     IF GetListItem(CHECKSTATES$, ftype%) = "ON" THEN
  291.         SrcDir$ = GetSymbolValue("STF_SRCDIR")
  292.         IF ftype% = APPFILES THEN
  293.             AddSectionFilesToCopyList "AppFiles", SrcDir$, DEST$
  294.         ELSEIF ftype% = OPTFILES1 THEN
  295.             AddSectionKeyFileToCopyList "OptFiles", OPT1OPT$, SrcDir$, DEST1OPT$
  296.         END IF
  297.         SrcDir$ = ""
  298.     END IF
  299. END SUB
  300.  
  301.  
  302. '**
  303. '** Purpose:
  304. '**     Recalculates disk space for the given option files and sets
  305. '**     the status info symbol "StatusItemsText".
  306. '** Arguments:
  307. '**     ftype% - type of files to add, one of the following:
  308. '**             APPFILES, OPTFILES1
  309. '** Returns:
  310. '**     none.
  311. '*************************************************************************
  312. SUB RecalcOptFiles (ftype%) STATIC
  313.     CursorSave% = ShowWaitCursor()
  314.     ClearCopyList
  315.     AddOptFilesToCopyList ftype%
  316.  
  317.     fExtra% = 0
  318.     IF ftype% = APPFILES THEN
  319.         ListSym$ = APPNEEDS$
  320.         IF GetListItem(CHECKSTATES$, APPFILES) = "ON" THEN
  321.             ''Add extra cost to Windows drive for ini/progman, etc.
  322.             ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
  323.             ReplaceListItem EXTRACOSTS$, ndrive%, "10240"
  324.             fExtra% = 1
  325.         END IF
  326.     ELSEIF ftype% = OPTFILES1 THEN
  327.         ListSym$ = OPT1NEEDS$
  328.     END IF
  329.  
  330.     StillNeed& = GetCopyListCost(EXTRACOSTS$, ListSym$, "")
  331.  
  332.     cost& = 0
  333.     FOR i% = 1 TO 26 STEP 1
  334.         cost&  = cost& + VAL(GetListItem(ListSym$, i%))
  335.     NEXT i%
  336.     ReplaceListItem STATUSTEXT$, ftype%, STR$(cost& / 1024) + " K"
  337.  
  338.     IF StillNeed& > 0 THEN
  339.         ReplaceListItem BIGLIST$, ftype%, "YES"
  340.     ELSE
  341.         ReplaceListItem BIGLIST$, ftype%, ""
  342.     END IF
  343.  
  344.     IF fExtra% THEN
  345.         ReplaceListItem EXTRACOSTS$, ndrive%, "0"
  346.     END IF
  347.     RestoreCursor CursorSave%
  348.     ListSym$ = ""
  349. END SUB
  350.  
  351.  
  352. '**
  353. '** Purpose:
  354. '**     Recalculates disk space and sets option status info according
  355. '**     to the current destination path.
  356. '** Arguments:
  357. '**     none.
  358. '** Returns:
  359. '**     none.
  360. '*************************************************************************
  361. SUB RecalcPath STATIC
  362.  
  363.     CursorSave% = ShowWaitCursor()
  364.  
  365.     RecalcOptFiles APPFILES
  366.     RecalcOptFiles OPTFILES1
  367.  
  368.     RestoreCursor CursorSave%
  369. END SUB
  370.  
  371.  
  372. '**
  373. '** Purpose:
  374. '**     Sets drive status info according to latest disk space calcs.
  375. '** Arguments:
  376. '**     none.
  377. '** Returns:
  378. '**     none.
  379. '*************************************************************************
  380. SUB SetDriveStatus STATIC
  381.  
  382.     drive$ = MID$(DEST$, 1, 1)
  383.     ndrive% = ASC(ucase$(drive$)) - ASC("A") + 1
  384.     cost& = VAL(GetListItem(APPNEEDS$, ndrive%)) + VAL(GetListItem(OPT1NEEDS$, ndrive%))
  385.     free& = GetFreeSpaceForDrive(drive$)
  386.     ReplaceListItem DRIVETEXT$, 1, drive$ + ":"
  387.     ReplaceListItem DRIVETEXT$, 2, STR$(cost& / 1024) + " K"
  388.     ReplaceListItem DRIVETEXT$, 3, STR$(free& / 1024) + " K"
  389.  
  390.     IF drive$ = WINDRIVE$ THEN
  391.         ReplaceListItem DRIVETEXT$, 4, ""
  392.         ReplaceListItem DRIVETEXT$, 5, ""
  393.         ReplaceListItem DRIVETEXT$, 6, ""
  394.     ELSE
  395.         ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
  396.         cost& = VAL(GetListItem(APPNEEDS$, ndrive%)) + VAL(GetListItem(OPT1NEEDS$, ndrive%))
  397.         IF cost& = 0 THEN
  398.             ReplaceListItem DRIVETEXT$, 4, ""
  399.             ReplaceListItem DRIVETEXT$, 5, ""
  400.             ReplaceListItem DRIVETEXT$, 6, ""
  401.         ELSE
  402.             free& = GetFreeSpaceForDrive(WINDRIVE$)
  403.             ReplaceListItem DRIVETEXT$, 4, WINDRIVE$ + ":"
  404.             ReplaceListItem DRIVETEXT$, 5, STR$(cost& / 1024) + " K"
  405.             ReplaceListItem DRIVETEXT$, 6, STR$(free& / 1024) + " K"
  406.         END IF
  407.     END IF
  408. END SUB
  409.  
  410.  
  411. '**
  412. '** Purpose:
  413. '**     Appends a file name to the end of a directory path,
  414. '**     inserting a backslash character as needed.
  415. '** Arguments:
  416. '**     szDir$  - full directory path (with optional ending "\")
  417. '**     szFile$ - filename to append to directory
  418. '** Returns:
  419. '**     Resulting fully qualified path name.
  420. '*************************************************************************
  421. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  422.     IF szDir$ = "" THEN
  423.         MakePath = szFile$
  424.     ELSEIF szFile$ = "" THEN
  425.         MakePath = szDir$
  426.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  427.         MakePath = szDir$ + szFile$
  428.     ELSE
  429.         MakePath = szDir$ + "\" + szFile$
  430.     END IF
  431. END FUNCTION
  432.  
  433.